package com.example.order.message;

import com.example.order.dto.OrderDTO;
import com.example.order.util.Console;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

@Component
@EnableBinding(StareamClient.class)
public class StreamReceiver {

    /**
     * 接受对象
     * @param object
     * @throws JsonProcessingException
     */
    @StreamListener(StareamClient.INPUT)
    @SendTo(StareamClient.INPUT2)
    public String process(OrderDTO object) throws JsonProcessingException {
        Console.log("StreamReceiver",object);
        return "recaived.";
    }
    @StreamListener(StareamClient.INPUT2)
    public void process2(String object) throws JsonProcessingException {
        Console.log(StareamClient.INPUT2,object);
    }




//    @StreamListener(StareamClient.INPUT)
//    public void process(Object object) throws JsonProcessingException {
//        Console.log("StreamReceiver",object);
//    }
}
